package gamagora.box2d
{
	import Box2D.Collision.Shapes.b2CircleShape;
	
	import org.flixel.FlxGroup;

	public class OSPhysicCircle extends OSPhysicSprite
	{
		protected var _radius:Number;
		
		public function OSPhysicCircle(x:Number=0, y:Number=0, radius:Number = 0, simpleGraphic:Class=null)
		{
			super(x, y, simpleGraphic);
			_nbSprites = 1;
			_radius = radius;
			width = _radius * 2;
			height = _radius * 2;
			_physicWidth = _radius * 2;
			_physicHeight = _radius * 2;
		}
		
		public override function create(group:FlxGroup):void
		{
			super.create(group);
			_physic.fixDef.shape = new b2CircleShape(_radius / OSPhysicWorld.ratio);
			_physic.create(x + _radius, y + (_radius / 2));
			_physic.fixture.SetUserData(_data);
		}
		
		public override function update():void
		{
			x = _physic.getX() - _radius;
			y = _physic.getY() - _radius;
			angle = _physic.getAngle();
		}
	}
}